package eip.chapter8.expiration.impl;

import java.util.Random;

import eip.chapter8.expiration.RestaurantInquiry;
import eip.chapter8.expiration.RestaurantInquiryService;
import eip.chapter8.expiration.RestaurantResponse;

public class RestaurantInquiryServiceImpl implements RestaurantInquiryService {
	
	/** list of possible responses */
	private RestaurantResponse[] possibleResponses = new RestaurantResponse[] {
			new RestaurantResponse("The royal duck","Space with a view on the lake is available.","accepted"),
			new RestaurantResponse("Lakeview restaurant","Tonight is reserved for a wedding.","rejected"),
			new RestaurantResponse("Yokohama","Space for two available at the hot plate.","accepted")
	};

	/** to select a random response */
	private static Random random = new Random(System.currentTimeMillis());
	
	/**
	 * Based on the inquiry generate a random response.
	 */
	public RestaurantResponse processInquiry(RestaurantInquiry inquiry) {
		RestaurantResponse response = possibleResponses[random.nextInt(possibleResponses.length)];
		return response;
	}

}
